﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using Newtonsoft.Json;
using System.IO;
using FantastPlatform.Framework.Core;
using System.Collections;

namespace FantastPlatform.Framework.Common.Serializable
{
    public class InterfaceConverter<T> :JsonConverter
    {
        public override bool CanConvert(Type objectType)
        {
            return true;
        }
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            serializer.Serialize(writer, value);
        }
        public override object ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer)
        {
            T entity = default(T);
            entity = serializer.Deserialize<T>(reader);
            return entity;
        }
        //public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        //{
        //    T entity = default(T);
        //    entity = serializer.Deserialize<T>(reader);
        //    return entity;
        //}
    }
}
